﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

namespace KC.Storage.Util.Extension
{
    public static class ExistenceExtensions
    {
        public static bool Exists(this CloudBlob blob)
        {
            try
            {
                blob.FetchAttributesAsync();
                return true;
            }
            catch (StorageException)
            {
                //if (e.ErrorCode == StorageErrorCode.ResourceNotFound)
                //{
                //    return false;
                //}
                throw;
            }
        }
        public static bool Exists(this CloudBlobContainer container)
        {
            try
            {
                container.FetchAttributesAsync();
                return true;
            }
            catch (StorageException)
            {
                //if (e.ErrorCode == StorageErrorCode.ResourceNotFound)
                //{
                //    return false;
                //}
                throw;
            }
        }
    }
}